package com.situ.mall.clone;

import lombok.Data;
import org.aspectj.weaver.patterns.PerObject;

//@Data
public class Person implements Cloneable{
    public Integer age;
    public int[] arr = {1, 2};

    public Person(Integer age) {
        this.age = age;
    }

    /*@Override
    protected Person clone(){
        try {
            return (Person) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }*/


    @Override
    public Person clone() {
        try {
            Person person = (Person) super.clone();
            person.arr = this.arr.clone(); //调用引用类型的clone方法
            return person;
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return null;
    }
}
